﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Configuration;

namespace nwrole.toolbox.mailservice.serverconsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("MailService server starting");

            string storageAccount = ConfigurationManager.AppSettings["StorageAccount"];
            string container = ConfigurationManager.AppSettings["BlobContainer"];
            string queue = ConfigurationManager.AppSettings["MessageQueue"];

            string intervalSecondsStr = ConfigurationManager.AppSettings["CheckIntervalSeconds"];
            int sleepSeconds = int.Parse(intervalSecondsStr);

            MailServiceServer server = new MailServiceServer(storageAccount, container, queue);

            while (true)
            {
                Console.WriteLine("Processing messages (" + DateTime.Now + ")");
                server.ProcessMessages();

                Thread.Sleep(sleepSeconds * 1000);
            }
        }
    }
}
